<?php
use backend\assets\AppAsset;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use frontend\widgets\Alert;
use yii\helpers\Url;
use backend\controllers\AdminController;
//use yii\widgets\Breadcrumbs;

$controller = Yii::$app->controller->id;
$action = Yii::$app->controller->action->id;
$list = AdminController::getGroup($controller, $action);

/* @var $this \yii\web\View */
/* @var $content string */

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>

	<?php $this->registerJsFile('@web/assets/admin/js/jquery.js'); ?>

<style rel="stylesheet">
	.container{
		width: 100%;
	}
</style>

</head>
<body>
    <?php $this->beginBody() ?>
    <div class="wrap">

        <?php
            NavBar::begin([
                'brandLabel' => '<img src="'.Url::to('@web/assets/admin/images/logo.png').'" alt="Yii Framework">',
                'brandUrl' => Url::home(true),
                'options' => [
                    'class' => 'navbar-inverse navbar-fixed-top',
                ],
            ]);

            if (Yii::$app->user->isGuest) {
                $menuItems[] = ['label' => '登陆', 'url' => ['/site/login']];
            } else {
				$menuItems = [
					['label' => '首页', 'url' => ['/site/index']],
					['label' => '资讯', 'url' => ['/article/index']],
					['label' => '用户', 'url' => ['/user/index']],
					['label' => '系统', 'url' => ['/sys/index']],
				];
            }
            echo Nav::widget([
                'options' => ['class' => 'navbar-nav navbar-left'],
                'items' => $menuItems,
            ]);
        ?>

		<?php if (!Yii::$app->user->isGuest) { ?>
			<form class="navbar-form navbar-left" action="" onsubmit="return false" method="get">
				<div class="input-group">
					<input type="text" class="form-control" name="q" placeholder="装饰物品">
						<span class="input-group-btn">
							<button type="submit" class="btn btn-default">
								<i class="fa fa-search"></i>
							</button>
						</span>
				</div>
			</form>

			<ul id="w3" class="navbar-nav navbar-right nav">
				<li>
					<a href=""><span class="fa fa-envelope-o"></span> </a>
				</li>
				<li class="dropdown">
					<a class="avatar dropdown-toggle" href="#" data-toggle="dropdown">
						<img src="<?= Url::to('@web/assets/admin/images/40_avatar_small.jpg')?>" alt="word1018808441" width="32" height="32">
						<b class="caret"></b>
					</a>
					<ul id="w4" class="dropdown-menu">
						<li>
							<a href="/user" tabindex="-1">
								<span class="fa fa-user fa-fw"></span>
								个人主页
							</a>
						</li>
						<li>
							<a href="/user/site/index" tabindex="-1">
								<span class="fa fa-cog fa-fw"></span>
								帐户设置
							</a>
						</li>

						<li class="divider"></li>

						<li>
							<a href="<?= Url::to(['site/logout']) ?>" data-method="post" tabindex="-1">
								<span class="fa fa-sign-out fa-fw"></span>
								退出
							</a>
						</li>
					</ul>
				</li>
			</ul>
		<?php } ?>

		<?php NavBar::end(); ?>

        <div class="container-fluid">

			<div style="width: 200px;float: left;margin-top: 50px;min-height: 2000px;position: fixed;background-color: #F5F5F5">
				<ul id="accordion" class="accordion">
					<?php foreach($list as $val): ?>
					<li>
						<div class="link">
							<i class="<?= $val->icon ?>"></i><?= $val->title ?><i class="fa fa-chevron-down"></i>
						</div>

						<?php if($val->tree): ?>
						<ul class="submenu">

							<?php foreach($val->tree as $v): ?>
							<li><a href="<?= Url::to([$v->url]) ?>"><?= $v->title ?></a></li>
							<?php endforeach ?>

						</ul>
						<?php endif ?>

					</li>
					<?php endforeach ?>
				</ul>
			</div>

			<div style="margin-left: 210px;margin-right:10px;margin-top: 70px">
				<h2 style="font-size: 22px;margin-top: 0">
					<?= $this->params['titles'] ?>
				</h2>
				<?= Alert::widget() ?>

				<?= $content ?>
			</div>

        </div>
    </div>

    <footer class="footer" style="margin-left: 200px">
        <div class="container">
        <p class="pull-left">&copy; My Company <?= date('Y') ?>
			版本：<?= Yii::getVersion() ?>
		</p>
        <p class="pull-right"><?= Yii::powered() ?></p>
        </div>
    </footer>


    <?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
